package GUI;

import java.util.ArrayList;

import javax.swing.JButton;

import Algorithms.BidirectionalStrategy;
import Algorithms.Context;
import Joc.Joc;
import Joc.JocStates;
import Operators.FarmerOperators;
import States.FarmerStates;
import Templates.Operator;
import Templates.State;

public class BidirectionalCommand extends JButton implements Command {

	private static final long serialVersionUID = 1L;
	
	public BidirectionalCommand(){
		super("Algoritm Bidirectional");
	}

	@Override
	public void execute() {
		SimulareDesenPanel.clearDesen();
		Joc j=Joc.getJocinstance();
		if(j.getState()==JocStates.LCV){
			ArrayList<Operator<FarmerStates>> farmerOperators=FarmerOperators.returnOperators();
			State<FarmerStates> FarmerInitialState=FarmerStates.initalState();
			ArrayList<State<FarmerStates>> FarmerFinalState=FarmerStates.finalStates();
			String FarmerBid="FarmerBid.txt";
			Context<FarmerStates> f=new Context<FarmerStates>(new BidirectionalStrategy<FarmerStates>());
			f.executeStrategy(FarmerInitialState,FarmerFinalState,farmerOperators,FarmerBid);
			MassagePanel.writeMessagePanel("S-a aplicat algoritmul Bidirectional!" );
		}
		else if (j.getState() == JocStates.CANI) {
			MassagePanel.writeMessagePanel("NU poate fi aplicat algoritmul Bidirectional!" );
		}
		else if (j.getState() == JocStates.PUZZLE) {
			MassagePanel.writeMessagePanel("NU poate fi aplicat algoritmul Bidirectional!" );
		}
	}

}
